<?php
include dirname(dirname(__FILE__)).'/admin-verify.php';
require dirname(__FILE__).'/functions.php';
$_name=addslashes($_POST['name']);
$_price=addslashes($_POST["price"]);
$_piecesPrice=addslashes($_POST["pieces-price"]);
$_number=addslashes($_POST["number"]);
$_describe="";
if (isset($_POST["describe"])) {
	$_describe=addslashes($_POST["describe"]);
}
$_storeName=addslashes($_POST["store-name"]);
$_goodsClassId=addslashes(getGoodsClassId($_POST['goods-class']));
$params=array(
				'name'=>'"'.$_name.'"',
			 	'price'=>$_price,
			  	'piece_price'=>$_piecesPrice,
			  	'number'=>$_number,
				'goods_class_id'=>$_goodsClassId,
				'goods_describe'=>'"'.$_describe.'"',
					
			  
);
if (addGoods($params)) {
	$goodsId=addslashes(getGoodsId($_name));
	$url=getHost()."/images/".$_storeName;
	$_params=array(
					'store_name'=>'"'.$_storeName.'"',
					'url'=>'"'.$url.'"',
					'goods_id'=>$goodsId
		
			
			
	);
		if (addPhoto($_params)){
			alertInfo("添加商品成功！",getHost().'/admin/goods-manage/index.php');
			exit();
			
		
	}else {
		unlink(dirname(dirname(dirname(__FILE__))).'/images/'.$_storeName);
		alertInfo("添加商品失败！",getHost().'/admin/goods-manage/index.php');
		exit();
		
		
	}
	
	
}
else {
	unlink(dirname(dirname(dirname(__FILE__))).'/image/'.$_storeName);
	alertInfo("添加商品失败！",getHost().'/admin/goods-manage/index.php');
	exit();
	
}




?>